//1. 建立请求对象

const htp = require('http');

//2. 创建服务器实例
const server = htp.createServer();

// 请求监听函数
server.on('request', (req, res) => {
        //req.url 请求地址  
        //req.methon 请求类型
        const url = req.url;
        const method = req.method;
        req.setHeader('Cookie', ['type=ninja', 'language=javascript']);
        const str = `Your request url is ${url}, 
        and request method is ${method}`
        console.log(str);
    })
    //4. 启动服务器
server.listen(80, () => {
    console.log('Server running at htpp://127.0.0.1');
})